package Java练习.面向对象综合练习.基础;

public class PhoneText {
    public static void main(String[] args) {
        //定义数组
        Phone[] arr=new Phone[3];
        //创建手机对象
        Phone p1=new Phone("vivo",1999,"白色");
        Phone p2=new Phone("小米",4999,"蓝色");
        Phone p3= new Phone("苹果",3999,"白色");
        //添加到数组
        arr[0]=p1;
        arr[1]=p2;
        arr[2]=p3;
        //遍历数组
        //求和
        int add=0;
        for (int i = 0; i < arr.length; i++) {
            add+=arr[i].getPrize();
        }
        //打印平均价格
        double avg=add*1.0/ arr.length;
        System.out.println("三部手机的平均价格为:"+avg);

    }
}
